﻿using RaytracerLib.MathLib;
using YAXLib;

namespace RaytracerLib.Volumes
{
    public class TransformOperationVolume : UnaryVolume
    {
        [YAXNode]
        public Matrix4 Transform { get; set; }

        public TransformOperationVolume(Volume a_childLayer, Matrix4 a_transform)
            : base(a_childLayer)
        {
            Transform = a_transform;
        }

        public override ColorFloat GetColor(Vector3 a_uvw, Intersection a_intersection)
        {
            return ChildVolume.GetColor(Transform * a_uvw, a_intersection);
        }

        public override Tangents GetTangents(Vector3 a_uvw, Vector3 a_tx, Vector3 a_ty,
            Intersection a_intersection)
        {
            return ChildVolume.GetTangents(Transform * a_uvw, Transform * a_tx,
                Transform * a_ty, a_intersection);
        }

        public override double GetValue(Vector3 a_uvw, Intersection a_intersection)
        {
            return ChildVolume.GetValue(Transform * a_uvw, a_intersection);
        }
    }
}